
/* this file is to do analysis for Facs-childcare*/
use c:\work4,clear

drop k1h*
ren afinc incfath
ren aminc incmoth
ren ap2 dbothprnt
g finc=incmoth+incfath if dbothprnt==1&incmoth>=0&incmoth<.&incfath>=0&incfath<.
replace finc=incmoth if dbothprnt==0&incmoth>=0&incmoth<.&agem>0&agem<.
replace finc=incfath if dbothprnt==0&incfath>=0&incfath<.&agef>0&agef<.
g dremote=1
replace dremote=0 if aremote==0|aremote==1

g lfinc=ln(finc)
drop if lfinc==.

drop if ind_soc==.|acoi==.|ind_phy==.|ind_lrn==.
drop if aborg==.
drop if wtbirth<=0
drop if highed_f==.&agef~=-9
/*Find out why the following bservation has missing father's low edu and year 12 edu*/
replace lowed_f=0 if lowed_f==. & certi_f==1
replace year12_f=0 if year12_f==. & certi_f==1

replace highed_f=0 if dbothprnt==0&agem>0&agem<.
replace certi_f=0 if dbothprnt==0&agem>0&agem<.
replace diploma_f=0 if dbothprnt==0&agem>0&agem<.
replace year12_f=0 if dbothprnt==0&agem>0&agem<.
replace lowed_f=0 if dbothprnt==0&agem>0&agem<.

replace highed_m=0 if dbothprnt==0&agef>0&agef<.
replace certi_m=0 if dbothprnt==0&agef>0&agef<.
replace diploma_m=0 if dbothprnt==0&agef>0&agef<.
replace year12_m=0 if dbothprnt==0&agef>0&agef<.
replace lowed_m=0 if dbothprnt==0&agef>0&agef<.
g wtbirth2 = wtbirth^2
g dpoi=0 if apoi==0
replace dpoi=1 if apoi>0
g dnoi=0 if anoi==0
replace dnoi=1 if anoi>0
replace agem=0 if agm==-9
replace agef=0 if agef==-9
g agem2=agem^2
 log using leigh.log,replace

count
reg acoi aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table3.doc, coefastr nocons bracket 3aster replace bdec(3) se ti("Table 3 OLS estimates for Overall index") ct("Model 5") rdec(3)
reg acoi aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table9.doc, coefastr nocons bracket 3aster replace bdec(3) se ti("Table 9 OLS estimates for Overall index") ct("Model 5") rdec(3)
reg acoi aborg sex age 
outreg using table3.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 1") rdec(3)
reg acoi sex age agem agem2 if agem>0
outreg using table9.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 1") rdec(3)

reg acoi aborg sex age  lfinc
outreg using table3.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 2") rdec(3)

reg acoi sex age agem agem2 lfinc  if agem>0
outreg using table9.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 2") rdec(3)

reg acoi aborg sex age lang_eng highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table3.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 3") rdec(3)
reg acoi aborg sex age lang_eng highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table9.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 3") rdec(3)

reg acoi aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table3.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 4") rdec(3)
reg acoi aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table9.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 4") rdec(3)

reg acoi aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem if dremote==0
outreg using table3.doc, coefastr nocons bracket 3aster append bdec(3) se  ct("Model 5, non-remote") rdec(3)
reg acoi aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 if dremote==0 &agem>0
outreg using table9.doc, coefastr nocons bracket 3aster append bdec(3) se  ct("Model 5, non-remote") rdec(3)


reg ind_lrn aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table4.doc, coefastr nocons bracket 3aster replace bdec(3) se ti("Table 4 OLS estimates for leraning index") ct("Model 5") rdec(3)

reg ind_lrn aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table10.doc, coefastr nocons bracket 3aster replace bdec(3) se ti("Table 10 OLS estimates for leraning index") ct("Model 5") rdec(3)

reg ind_lrn aborg sex age 
outreg using table4.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 1") rdec(3)

reg ind_lrn sex age agem agem2 if agem>0
outreg using table10.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 1") rdec(3)

reg ind_lrn aborg sex age lfinc
outreg using table4.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 2") rdec(3)
reg ind_lrn aborg sex age agem agem2 lfinc if agem>0
outreg using table10.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 2") rdec(3)

reg ind_lrn aborg sex age lang_eng highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table4.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 3") rdec(3)

reg ind_lrn aborg sex age lang_eng highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table10.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 3") rdec(3)

reg ind_lrn aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table4.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 4") rdec(3)
reg ind_lrn aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table10.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 4") rdec(3)

reg ind_lrn aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem if dremote==0
outreg using table4.doc, coefastr nocons bracket 3aster append bdec(3) se  ct("Model 5, non-remote") rdec(3)
reg ind_lrn aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 if dremote==0& agem>0
outreg using table10.doc, coefastr nocons bracket 3aster append bdec(3) se  ct("Model 5, non-remote") rdec(3)

reg ind_soc aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table5.doc, coefastr nocons bracket 3aster replace bdec(3) se ti("Table 5 OLS estimates for Social index") ct("Model 5") rdec(3)
reg ind_soc aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table11.doc, coefastr nocons bracket 3aster replace bdec(3) se ti("Table 11 OLS estimates for Social index") ct("Model 5") rdec(3)

reg ind_soc aborg sex age 
outreg using table5.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 1") rdec(3)
reg ind_soc sex age agem agem2 if agem>0
outreg using table11.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 1") rdec(3)

reg ind_soc aborg sex age lfinc
outreg using table5.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 2") rdec(3)
reg ind_soc sex age agem agem2 lfinc if agem>0
outreg using table11.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 2") rdec(3)

reg ind_soc aborg sex age lang_eng highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table5.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 3") rdec(3)
reg ind_soc aborg sex age lang_eng highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table11.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 3") rdec(3)

reg ind_soc aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table5.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 4") rdec(3)
reg ind_soc aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table11.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 4") rdec(3)

reg ind_soc aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem if dremote==0
outreg using table5.doc, coefastr nocons bracket 3aster append bdec(3) se  ct("Model 5, non-remote") rdec(3)
reg ind_soc aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 if dremote==0& agem>0
outreg using table11.doc, coefastr nocons bracket 3aster append bdec(3) se  ct("Model 5, non-remote") rdec(3)

reg ind_phy  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem 

*dprobit dnoi  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem 


dprobit dnoi  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table6.doc, coefastr nocons bracket 3aster replace bdec(3) se ti("Table 6 Probit estimates of marginal effects on probabilities of being in problematic area (overall)") ct("Model 5") rdec(3)
dprobit dnoi  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table12.doc, coefastr nocons bracket 3aster replace bdec(3) se ti("Table 12 Probit estimates of marginal effects on probabilities of being in problematic area (overall)") ct("Model 5") rdec(3)

dprobit dnoi aborg sex age 
outreg using table6.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 1") rdec(3)
dprobit dnoi sex age agem agem2 if agem>0
outreg using table12.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 1") rdec(3)


dprobit dnoi aborg sex age lfinc
outreg using table6.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 2") rdec(3)
dprobit dnoi sex age agem agem2 lfinc if agem>0
outreg using table12.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 2") rdec(3)

dprobit dnoi aborg sex age lang_eng highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table6.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 3") rdec(3)
dprobit dnoi aborg sex age lang_eng highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table12.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 3") rdec(3)

dprobit dnoi aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table6.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 4") rdec(3)
dprobit dnoi aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table12.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 4") rdec(3)

dprobit dnoi aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem if dremote==0
outreg using table6.doc, coefastr nocons bracket 3aster append bdec(3) se  ct("Model 5, non-remote") rdec(3)
dprobit dnoi aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 if dremote==0&agem>0
outreg using table12.doc, coefastr nocons bracket 3aster append bdec(3) se  ct("Model 5, non-remote") rdec(3)

dprobit ansco  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table7.doc, coefastr nocons bracket 3aster replace bdec(3) se ti("Table 7 Probit estimates of marginal effects on probabilities of being in problematic area (social)") ct("Model 5") rdec(3)
dprobit ansco  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table13.doc, coefastr nocons bracket 3aster replace bdec(3) se ti("Table 13 Probit estimates of marginal effects on probabilities of being in problematic area (social)") ct("Model 5") rdec(3)

dprobit ansco aborg sex age 
outreg using table7.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 1") rdec(3)
dprobit ansco sex age agem agem2 if agem>0
outreg using table13.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 1") rdec(3)

dprobit ansco aborg sex age lfinc
outreg using table7.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 2") rdec(3)
dprobit ansco sex age agem agem2 lfinc if agem>0
outreg using table13.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 2") rdec(3)

dprobit ansco aborg sex age lang_eng highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table7.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 3") rdec(3)
dprobit ansco aborg sex age lang_eng highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table13.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 3") rdec(3)

dprobit ansco aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table7.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 4") rdec(3)
dprobit ansco aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table13.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 4") rdec(3)

dprobit ansco aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem if dremote==0
outreg using table7.doc, coefastr nocons bracket 3aster append bdec(3) se  ct("Model 5, non-remote") rdec(3)
dprobit ansco aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 if dremote==0& agem>0
outreg using table13.doc, coefastr nocons bracket 3aster append bdec(3) se  ct("Model 5, non-remote") rdec(3)

dprobit anlco  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table8.doc, coefastr nocons bracket 3aster replace bdec(3) se ti("Table 8 Probit estimates of marginal effects on probabilities of being in problematic area (learning)") ct("Model 5") rdec(3)
dprobit anlco  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table14.doc, coefastr nocons bracket 3aster replace bdec(3) se ti("Table 14 Probit estimates of marginal effects on probabilities of being in problematic area (learning)") ct("Model 5") rdec(3)

dprobit anlco aborg sex age 
outreg using table8.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 1") rdec(3)
dprobit anlco sex age agem agem2 if agem>0
outreg using table14.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 1") rdec(3)

dprobit anlco aborg sex age lfinc
outreg using table8.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 2") rdec(3)
dprobit anlco sex age agem agem2 lfinc if agem>0
outreg using table14.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 2") rdec(3)

dprobit anlco aborg sex age lang_eng highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table8.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 3") rdec(3)
dprobit anlco aborg sex age lang_eng highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table14.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 3") rdec(3)

dprobit anlco aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem dremote
outreg using table8.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 4") rdec(3)
dprobit anlco aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 dremote if agem>0
outreg using table14.doc, coefastr nocons bracket 3aster append bdec(3) se ct("Model 4") rdec(3)

dprobit anlco aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem if dremote==0
outreg using table8.doc, coefastr nocons bracket 3aster append bdec(3) se  ct("Model 5, non-remote") rdec(3)
dprobit anlco aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem agem2 if dremote==0& agem>0
outreg using table14.doc, coefastr nocons bracket 3aster append bdec(3) se  ct("Model 5, non-remote") rdec(3)


/*
dprobit anpco  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem 
dprobit dpoi  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem 
dprobit apsco  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem 
dprobit aplco  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem 
dprobit appco  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem 



mlogit apoi  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem, baseoutcome(0)
mlogit anoi  aborg sex age lang_eng wtbirth highed_m certi_m diploma_m lowed_m highed_f certi_f diploma_f lowed_f dsib dysib lfinc dbothprnt agem, baseoutcome(0)
*/





sum acoi ind_phy ind_soc ind_lrn aplco apsco appco anlco ansco anpco anoi apoi  aborg sex age lang_eng wtbirth  dsib dysib finc dbothprnt dremote
sum agem highed_m certi_m diploma_m lowed_m  if e(sample) & agem>0
sum agef highed_f certi_f diploma_f lowed_f if e(sample) & agef>0
tab apoi anoi
log close


/*

ren k1fa1a dftwk_f
ren k1fa1b dptwk_f
ren k1fa1c dcswk_f
ren k1fa1d dunem_f
ren k1fa1e dftstd_f
ren k1fa1f dptstd_f
ren k1fa1g dhomeduty_f
ren k1fa1h dretire_f
ren k1fa1i donleave_f
ren k1fa1j dothact_f
ren k1ma1a dftwk_m
ren k1ma1b dptwk_m
ren k1ma1c dcswk_m
ren k1ma1d dunem_m
ren k1ma1e dftstd_m
ren k1ma1f dptstd_m
ren k1ma1g dhomeduty_m
ren k1ma1h dretire_m
ren k1ma1i donleave_m
ren k1ma1j dothact_m
ren k1fd2 prhour_f
ren k1md2 prhour_m
ren k1fd3 dhrchg_f
ren k1fd4 dhrchgp_f
ren k1fd5 jobsecure_f
ren k1md3 dhrchg_m
ren k1md4 dhrchgp_m
ren k1md5 jobsecure_m
ren k1ff4 fairshccare_f
ren k1ff5 fairchdom_f
ren k1mf4 fairshccare_m
ren k1mf5 fairchdom_m

drop apcod* pcodes ap*scd ateachd aedid ancac  k1p* k1s* k1t* kcfc ap1* ap2* k1j*  k1f* k1m*
recode health -2=.
recode relate21 -9=.
recode cchourtot -4/-2=.
recode cchour_1 -4/-1=.
recode cchour_2 -4/-1=.
recode cchour_3 -4/-1=.
drop if dretire_m==1
recode wkhr_m -4/-1=.
replace wkhr_m=0 if wkhr_m==.&dftwk_m==0& dptwk_m==0
recode wkhr_f -4/-1=.
replace wkhr_f=0 if wkhr_f==.&dftwk_f==0& dptwk_f==0
replace wkhr_m=0 if agem~=-9&wkhr_m==-9
replace wkhr_f=0 if agef~=-9&wkhr_f==-9

/*
replace dftwk_m=1 if dftwk_m==-9&wkhr_m>=30&wkhr_m<.
replace dftwk_f=1 if dftwk_f==-9&wkhr_f>=30&wkhr_f<.
replace dptwk_m=0 if dptwk_m==-9&wkhr_m>=30&wkhr_m<.
replace dptwk_f=0 if dptwk_f==-9&wkhr_f>=30&wkhr_f<.
replace dptwk_m=1 if dptwk_m==-9&wkhr_m>0&wkhr_m<30
replace dptwk_f=1 if dptwk_f==-9&wkhr_f>0&wkhr_f<30
replace dftwk_m=0 if dftwk_m==-9&wkhr_m>=0&wkhr_m<30
replace dftwk_f=0 if dftwk_f==-9&wkhr_f>=0&wkhr_f<30
replace dptwk_m=0 if dptwk_m==-9&wkhr_m==0
replace dptwk_f=0 if dptwk_f==-9&wkhr_f==0
recode dptwk* (-4/-1=.)
recode dftwk* (-4/-1=.)
replace dhomeduty_m=0 if dhomeduty_m==-9&(dftwk_m==1|dptwk_m==1)
replace dhomeduty_f=0 if dhomeduty_f==-9&(dftwk_f==1|dptwk_f==1)
*/

drop dftwk* dptwk*
g dftwk_m=0 if wkhr_m~=.&wkhr_m~=-9
replace dftwk_m=1 if wkhr_m>=30&wkhr_m<.
g dptwk_m=0 if wkhr_m~=.&wkhr_m~=-9
replace dptwk_m=1 if wkhr_m>0&wkhr_m<30
g dnonp_m=0 if wkhr_m~=.&wkhr_m~=-9
replace dnonp_m=1 if wkhr_m==0

g dftwk_f=0 if wkhr_f~=.&wkhr_f~=-9
replace dftwk_f=1 if wkhr_f>=30&wkhr_f<.
g dptwk_f=0 if wkhr_f~=.&wkhr_f~=-9
replace dptwk_f=1 if wkhr_f>0&wkhr_f<30
g dnonp_f=0 if wkhr_f~=.&wkhr_f~=-9
replace dnonp_f=1 if wkhr_f==0
replace wkhr_f=0 if  wkhr_f==.& dhomeduty_f==1& dftwk_f==0&dptwk_f==0&dnonp_f==0&agef~=-9
replace wkhr_m=0 if  wkhr_m==.& dhomeduty_m==1& dftwk_m==0&dptwk_m==0&dnonp_m==0&agem~=-9

drop if  dftwk_f==0&dptwk_f==0&dnonp_f==0&agef~=-9
drop if  dftwk_m==0&dptwk_m==0&dnonp_m==0&agem~=-9

recode noccare -4=.
recode cchourtot -9=.
recode cchour_1 -9=.
recode cchour_2 -9=.
recode cchour_3 -9=.
recode cchour_m -9=.
recode cchour_past -9=.
recode noccare (3/5=3)


sum cchour*
g lfp_m=1 if dftwk_m==1|dptwk_m==1
replace lfp_m=0 if dftwk_m==0&dptwk_m==0
g lfp_f=1 if dftwk_f==1|dptwk_f==1
replace lfp_f=0 if dftwk_f==0&dptwk_f==0


* log using fac_childcare.log,replace
tab noccare if cctype_m==1
 tab noccare if lfp_m==1&cctype_m==1
 tab noccare if dftwk_m==1&cctype_m==1
 tab noccare if lfp_m==0&cctype_m==1
tab noccare if dbothprnt==1&cctype_m==1
tab noccare if dbothprnt==0&cctype_m==1

tab noccare if cctype_m>1&cctype_m<.
 tab noccare if lfp_m==1&cctype_m>1&cctype_m<.

 tab noccare if dftwk_m==1&cctype_m>1&cctype_m<.

 tab noccare if lfp_m==0&cctype_m>1&cctype_m<.

tab noccare if dbothprnt==1&cctype_m>1&cctype_m<.

tab noccare if dbothprnt==0&cctype_m>1&cctype_m<.

tab noccare 
 tab noccare if lfp_m==1
 tab noccare if dftwk_m==1
 tab noccare if lfp_m==0
tab noccare if dbothprnt==1
tab noccare if dbothprnt==0


replace wkhr_f=0 if agef==-9
replace wkhr_m=0 if agem==-9
recode incband -99/-2=.
recode incfath (-99=.) (-3/-1=.)
recode incfath (-9=0)
recode incmoth (-99=.) (-3/-1=.)
recode incmoth (-9=0)

replace highed_m=0 if agem==-9
replace highed_f=0 if agef==-9
replace diploma_m=0 if agem==-9
replace diploma_f=0 if agef==-9
replace certi_m=0 if agem==-9
replace certi_f=0 if agef==-9
replace year12_m=0 if agem==-9
replace year12_f=0 if agef==-9
replace lowed_m=0 if agem==-9
replace lowed_f=0 if agef==-9
g finc=incmoth+incfath
g lfinc=ln(finc)
replace dfath=1 if dbothprnt==1
*drop if dfath==0
replace lfp_f=0 if agef==-9
replace lfp_m=0 if agem==-9
 mlogit noccare wkhr_m lfp_m highed_m diploma_m certi_m lfp_f aborg lfinc dbothprnt agem noldsib ageynst lang_eng
*mfx,predict(p outcome(0))
*mfx,predict(p outcome(1))
*mfx,predict(p outcome(2))
*mfx,predict(p outcome(3))


* mlogit noccare wkhr_m lfp_m highed_m diploma_m certi_m lfp_f aborg lfinc dbothprnt agem noldsib ageynst lang_eng if cctype_m==1
*mfx if cctype_m==1,predict(p outcome(0))
*mfx if cctype_m==1,predict(p outcome(1))
*mfx if cctype_m==1,predict(p outcome(2))
*mfx if cctype_m==1,predict(p outcome(3))


g xx=0 
replace xx=1 if noccare>0&noccare<.
 logit xx wkhr_m lfp_m highed_m diploma_m certi_m lfp_f aborg lfinc dbothprnt agem noldsib ageynst lang_eng if cctype_m==1


 mlogit noccare wkhr_m lfp_m highed_m diploma_m certi_m lfp_f aborg lfinc dbothprnt agem noldsib ageynst lang_eng if cctype_m>1&cctype_m<.

*mfx if cctype_m>1&cctype_m<.,predict(p outcome(1))
*mfx if cctype_m>1&cctype_m<.,predict(p outcome(2))
*mfx if cctype_m>1&cctype_m<.,predict(p outcome(3))



g caret=0 if dccare==1&cctype_m>1&cctype_m<.
label var caret "one formal care only, more formal care, mixed with informal"
replace caret=1 if dothcare==2&caret==0&cctype_m>1&cctype_m<.
replace caret=2 if dothcare==1&caret~=.&cctype_m>1&cctype_m<.
replace caret=3 if dothcare==1&(cctype_1==5|cctype_2==5|cctype_3==5)&caret~=.&cctype_m>1&cctype_m<.
 mlogit caret wkhr_m lfp_m highed_m diploma_m certi_m lfp_f aborg lfinc dbothprnt nsib ageynst agem lang_eng if caret>0
*mfx,predict(p outcome(1))
*mfx,predict(p outcome(2))
*mfx,predict(p outcome(3))


replace caret=1 if dothcare==2&cctype_m==1
replace caret=2 if dothcare==1&cctype_m==1
replace caret=3 if dothcare==1&(cctype_1==5|cctype_2==5|cctype_3==5)&cctype_m==1

g caret0=0 if dccare==1&cctype_m==1
label var caret "no care, formal care only, informal, mixed with informal"
replace caret0=1 if dothcare==2&caret0==0&cctype_m==1
replace caret0=2 if dothcare==1&caret0~=.&cctype_m==1&(cctype_1~=5&cctype_2~=5&cctype_3~=5)
replace caret0=3 if dothcare==1&caret0~=.&cctype_m==1&(cctype_1>=5&cctype_2>=5&cctype_3>=5)
replace caret0=4 if dothcare==1&caret0~=2&caret0~=3&caret0~=.&cctype_m==1
 mlogit caret0 wkhr_m lfp_m highed_m diploma_m certi_m lfp_f aborg lfinc dbothprnt nsib ageynst agem lang_eng 
*mfx,predict(p outcome(2))
*mfx,predict(p outcome(3))
*mfx,predict(p outcome(4))



*replace cchourtot=cchourtot-cchour_m if cctype_m==1
sum cchourtot
sum cchourtot if cchourtot>0
tab noccare,sum(cchourtot)
tab dbothprnt if cchourtot>0,sum(cchourtot)
tab lfp_m if cchourtot>0,sum(cchourtot)
tab lfp_f if cchourtot>0,sum(cchourtot)

sum cchourtot if dftwk_m==1 &cchourtot>0
sum cchourtot if dptwk_m==1&cchourtot>0

sum cchourtot if dftwk_f==1&cchourtot>0

sum cchourtot if dptwk_f==1&cchourtot>0


sum cchourtot if (dftwk_m==1&dftwk_f==1)&dbothprnt==1&cchourtot>0

sum cchourtot if lfp_m==0&dftwk_f==1&dbothprnt==1&cchourtot>0

sum cchourtot if dftwk_m==1&lfp_f==0&dbothprnt==1&cchourtot>0

sum cchourtot if lfp_m==0&lfp_f==0&dbothprnt==1&cchourtot>0

sum cchourtot if dptwk_m==1&dftwk_f==1&dbothprnt==1&cchourtot>0

sum cchourtot if dptwk_m==1&dptwk_f==1&dbothprnt==1&cchourtot>0

sum cchourtot if dftwk_m==1&dptwk_f==1&dbothprnt==1&cchourtot>0

sum cchourtot if dptwk_m==1&lfp_f==0&dbothprnt==1&cchourtot>0

sum cchourtot if lfp_m==0&dptwk_f==1&dbothprnt==1&cchourtot>0

*tab caret if cchourtot>0,sum(cchourtot)
g wkhr2=wkhr_m^2
g wkhr3=wkhr_m^3
g wkhr4=wkhr_m^4
g agem2=agem^2
g lfplone=lfp_m*dbothprnt
 reg cchourtot wkhr_m lfp_m highed_m diploma_m certi_m lfp_f aborg lfinc dbothprnt lfplone agem agem2 wkhr2  wkhr3 nynsib noldsib ageynst lang_eng if cchourtot>0


sum cchourtot if cctype_m==1
sum cchourtot if cchourtot>0&cctype_m==1
tab noccare if cctype_m==1,sum(cchourtot)
tab dbothprnt if cchourtot>0&cctype_m==1,sum(cchourtot)
tab lfp_m if cchourtot>0&cctype_m==1,sum(cchourtot)
tab lfp_f if cchourtot>0&cctype_m==1,sum(cchourtot)
sum cchourtot if dftwk_m==1 &cchourtot>0&cctype_m==1
sum cchourtot if dptwk_m==1&cchourtot>0&cctype_m==1
sum cchourtot if dftwk_f==1&cchourtot>0&cctype_m==1
sum cchourtot if dptwk_f==1&cchourtot>0&cctype_m==1
sum cchourtot if (dftwk_m==1&dftwk_f==1)&dbothprnt==1&cchourtot>0&cctype_m==1
sum cchourtot if lfp_m==0&dftwk_f==1&dbothprnt==1&cchourtot>0&cctype_m==1
sum cchourtot if dftwk_m==1&lfp_f==0&dbothprnt==1&cchourtot>0&cctype_m==1
sum cchourtot if lfp_m==0&lfp_f==0&dbothprnt==1&cchourtot>0&cctype_m==1
sum cchourtot if dptwk_m==1&dftwk_f==1&dbothprnt==1&cchourtot>0&cctype_m==1
sum cchourtot if dptwk_m==1&dptwk_f==1&dbothprnt==1&cchourtot>0&cctype_m==1
sum cchourtot if dftwk_m==1&dptwk_f==1&dbothprnt==1&cchourtot>0&cctype_m==1
sum cchourtot if dptwk_m==1&lfp_f==0&dbothprnt==1&cchourtot>0&cctype_m==1
sum cchourtot if lfp_m==0&dptwk_f==1&dbothprnt==1&cchourtot>0&cctype_m==1
tab caret0 if cchourtot>0&cctype_m==1,sum(cchourtot)
 reg cchourtot wkhr_m lfp_m highed_m diploma_m certi_m lfp_f aborg lfinc dbothprnt lfplone agem agem2 wkhr2  wkhr3 nynsib noldsib ageynst lang_eng if cchourtot>0&cctype_m==1

sum cchourtot if cctype_m>1&cctype_m<.

sum cchourtot if cchourtot>0&cctype_m>1&cctype_m<.

tab noccare if cctype_m>1&cctype_m<.,sum(cchourtot)
tab dbothprnt if cchourtot>0&cctype_m>1&cctype_m<.,sum(cchourtot)
tab lfp_m if cchourtot>0&cctype_m>1&cctype_m<.,sum(cchourtot)
tab lfp_f if cchourtot>0&cctype_m>1&cctype_m<.,sum(cchourtot)

sum cchourtot if dftwk_m==1 &cchourtot>0&cctype_m>1&cctype_m<.

sum cchourtot if dptwk_m==1&cchourtot>0&cctype_m>1&cctype_m<.

sum cchourtot if dftwk_f==1&cchourtot>0&cctype_m>1&cctype_m<.

sum cchourtot if dptwk_f==1&cchourtot>0&cctype_m>1&cctype_m<.

sum cchourtot if (dftwk_m==1&dftwk_f==1)&dbothprnt==1&cchourtot>0&cctype_m>1&cctype_m<.

sum cchourtot if lfp_m==0&dftwk_f==1&dbothprnt==1&cchourtot>0&cctype_m>1&cctype_m<.

sum cchourtot if dftwk_m==1&lfp_f==0&dbothprnt==1&cchourtot>0&cctype_m>1&cctype_m<.

sum cchourtot if lfp_m==0&lfp_f==0&dbothprnt==1&cchourtot>0&cctype_m>1&cctype_m<.

sum cchourtot if dptwk_m==1&dftwk_f==1&dbothprnt==1&cchourtot>0&cctype_m>1&cctype_m<.

sum cchourtot if dptwk_m==1&dptwk_f==1&dbothprnt==1&cchourtot>0&cctype_m>1&cctype_m<.

sum cchourtot if dftwk_m==1&dptwk_f==1&dbothprnt==1&cchourtot>0&cctype_m>1&cctype_m<.

sum cchourtot if dptwk_m==1&lfp_f==0&dbothprnt==1&cchourtot>0&cctype_m>1&cctype_m<.

sum cchourtot if lfp_m==0&dptwk_f==1&dbothprnt==1&cchourtot>0&cctype_m>1&cctype_m<.

tab caret if cchourtot>0&cctype_m>1&cctype_m<.,sum(cchourtot)
 reg cchourtot wkhr_m lfp_m highed_m diploma_m certi_m lfp_f aborg lfinc dbothprnt lfplone agem agem2 wkhr2  wkhr3 nynsib noldsib ageynst lang_eng if cchourtot>0&cctype_m>1&cctype_m<.

tab caret if cctype_m>1&cctype_m<.
tab caret if cctype_m>1&cctype_m<.&lfp_m==1

tab caret if cctype_m>1&cctype_m<.&lfp_m==0
tab caret if cctype_m>1&cctype_m<.&dftwk_m==1
tab caret if cctype_m>1&cctype_m<.&dptwk_m==1
tab caret if cctype_m>1&cctype_m<.&dbothprnt==1
tab caret if cctype_m>1&cctype_m<.&dbothprnt==0

/*
log using fac_childcare.log,append


replace caret=1 if dothcare==2&cctype_m==1
replace caret=2 if dothcare==1&cctype_m==1
replace caret=3 if dothcare==1&(cctype_1==5|cctype_2==5|cctype_3==5)&cctype_m==1

tab caret if cchourtot>0&cctype_m==1,sum(cchourtot)
replace noccare=noccare+1 if cctype_m==1
tab noccare if cctype_m==1,sum(cchourtot)



*/
*/
